<?php

/**
 * Coords actions.
 *
 * @package    mathematica
 * @subpackage Coords
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class CoordsActions extends sfActions
{
  public function executeIndex($request)
  {
  	$use_case = $request->getParameter('use_case_id');
  	//$use_case=1;
  	$criteria = new Criteria();
  	$criteria->add(CoordsPeer::ID_USE_CASE,$use_case);
  	
    $this->coordsList = CoordsPeer::doSelect($criteria);
    $this->useCase = UseCasePeer::retrieveByPK($use_case);
  }

  public function executeCreate($request)
  {
  	$this->use_case_id = $request->getParameter('use_Case_id');
    $this->form  = new CoordsForm();
    Deb::print_r($this->form);
    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
  	$use_case_id = $request->getParameter('use_Case_id'); 
    $this->form = new CoordsForm(CoordsPeer::retrieveByPk($request->getParameter('id')));
  }

  public function executeUpdate($request)
  {
  	$use_case_id = $request->getParameter('use_Case_id'); 
    $this->forward404Unless($request->isMethod('post'));
    //Deb::print_r($request->getParameterHolder()->getAll());

    $this->form = new CoordsForm(CoordsPeer::retrieveByPk($request->getParameter('id')));

    $this->form->bind($request->getParameter('coords'));
    if ($this->form->isValid())
    {
      
      $coords = $this->form->save();

      $this->redirect('UseCase/index');
      //$this->redirect('Coords/edit?id='.$coords->getId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($coords = CoordsPeer::retrieveByPk($request->getParameter('id')));

    $coords->delete();

    $this->redirect('Coords/index');
  }
}
